package com.yjy.fuyao.stu.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 课程
 * </p>
 *
 * @author yjy
 * @since 2021-08-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("course")
@ApiModel(value="Course对象", description="课程")
@Document(indexName = "course",shards = 6,replicas = 3)
public class Course implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String COURSE_DRAFT = "未发布";
    public static final String COURSE_NORMAL = "已发布待审核";
    public static final String COURSE_PASS = "审核通过";
    public static final String COURSE_NOPASS = "审核不通过";

    public static final Integer USER_UP = 0;
    public static final Integer TEACHER_UP = 1;

    @Id
    @ApiModelProperty(value = "课程ID")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    @Field(type = FieldType.Auto)
    @ApiModelProperty(value = "课程讲师ID")
    private String teacherId;

    @Field(type = FieldType.Auto)
    @ApiModelProperty(value = "课程专业ID")
    private String subjectId;

    @Field(type = FieldType.Auto)
    @ApiModelProperty(value = "课程专业父级ID")
    private String subjectParentId;

    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    @ApiModelProperty(value = "课程标题")
    private String title;

    @Field(type = FieldType.Double)
    @ApiModelProperty(value = "课程销售价格，设置为0则可免费观看")
    private BigDecimal price;

    @Field(type = FieldType.Integer)
    @ApiModelProperty(value = "总课时")
    private Integer lessonNum;

    @Field(type = FieldType.Text)
    @ApiModelProperty(value = "课程封面图片路径")
    private String cover;

    @Field(type = FieldType.Long)
    @ApiModelProperty(value = "销售数量")
    private Long buyCount;

    @Field(type = FieldType.Long)
    @ApiModelProperty(value = "浏览数量")
    private Long viewCount;

    @Field(type = FieldType.Long)
    @ApiModelProperty(value = "课程总评分")
    private Long rate;

    @Field(type = FieldType.Long)
    @ApiModelProperty(value = "评分人数")
    private Long rateCount;

    @Field(type = FieldType.Long)
    @ApiModelProperty(value = "乐观锁")
    private Long version;

    @Field(type = FieldType.Text)
    @ApiModelProperty(value = "课程状态 Draft未发布  Normal已发布")
    private String status;

    @Field(type = FieldType.Integer)
    @ApiModelProperty(value = "课程类型")
    private Integer type;

    @Field(type = FieldType.Boolean)
    @ApiModelProperty(value = "逻辑删除 1（true）已删除， 0（false）未删除")
    @TableField("is_deleted")
    @TableLogic
    private Boolean deleted;

    @Field(type = FieldType.Date,format = DateFormat.date_time)
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime gmtCreate;

    @Field(type = FieldType.Date,format = DateFormat.date_time)
    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime gmtModified;


}
